#include<bits/stdc++.h>
using namespace std;
#define ll long long

int T;
int n,m,L,V;
struct Node{
    int d,v,a;
}c[100050];
int p[100050];

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    for(int i=1;i<=T;++i){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int j=1;j<=n;++j){
            scanf("%d%d%d",&c[j].d,&c[j].v,&c[j].a);
        }
        for(int j=1;j<=m;++j){
            scanf("%d",&p[j]);
        }
        sort(p+1,p+m+1);
        int cnt=0;
        for(int j=1;j<=n;++j){
            if(c[j].d>p[m]){
                continue;
            }
            ll sty=1ll*c[j].v*c[j].v+2ll*c[j].a*(p[m]-c[j].d);
            if(sty>1ll*V*V){
                ++cnt;
            }
        }
        printf("%d %d\n",cnt,(cnt==0?m:m-1));
    }
    return 0;
}
